<?php

if (isset($_FILES['image_file'])) {
    unset($error);
    $extensions_ok = array('png', 'gif', 'jpg', 'jpeg', 'JPG', 'bmp');
    $folder_path = 'C:\\Apache24\\htdocs\\pics\\'; //Path to image file
    if (!in_array(substr(strrchr($_FILES['image_file']['name'], '.'), 1), $extensions_ok)) {
        $error = 'This file is not a picture!';
    }
    if (!isset($error)) {
        $i_pos_point = strrpos($_FILES['image_file']['name'], '.');
        $s_extension = substr($_FILES['image_file']['name'], $i_pos_point, strlen($_FILES['image_file']['name']) - $i_pos_point);
        $file_name = date('Y_m_d_H_i') . $s_extension;
        move_uploaded_file($_FILES['image_file']['tmp_name'], $folder_path . $file_name);
        echo('OK');
    }
}
if (isset($error)) {
    echo($error);
}
?>
